Saturday, May 31, 2014

Write a program to declare an integer array of 50 elements which gets 35 numbers from user and print rest of 15 as ZEROS.

//Exercise 1:Write a program to declare an integer array of 50 elements.
//A. Write a function getArray() to get array input from the user  that will be used to initialize the first thirty  five (35) elements of the array by getting input from the user. The rest of the 15 entries would be set to zero (0).
#include<stdio.h>
void header()
{
    printf("\n\n\n\n\n\n\n\t\tBUILT AND DESIGNED BY >> ARSLAN UD DIN SHAFIQ\n\n\t\tWebsite>>\twww.CWorldbyAS.blogspot.com\n");
    printf("\n\t\tCOMSATS Institute of Information Technology,\n\n\t\t\t\t\t  Lahore , Pakistan\n\n\n");
}
int main()
{
    int a[50]={0},i;
    header();
    system("pause");
    system("cls");
    for(i=0;i<35;i++)
{
     printf("%d Number : ",i+1);
     scanf("%d",&a[i]);
     printf("\n");
}
    for(i=0;i<50;i++)
    printf(" %d ",a[i]);
    getch();
}

No comments:

Post a Comment