Tuesday, August 2, 2022

program to find the sum of n input numbers

/* program to find the sum of n input numbers*/

#include<stdio.h>

#include<conio.h>

main()

{

int i,n,number[100],temp=0;

printf ("Enter the number of element:");

scanf("%d",&n);

printf("\n Enter the number");

for(i=0;i<n;i++)

{

scanf("%d",&number[i]);

}

for(i=0;i<n;i++)

{

temp=temp+number[i];

}

//printing the sum of the number

printf("\n The sum of the whole number is: %d",temp);

getch();

}




program to input the age of students and find the youngest among them

 /* program to input the age of students and find the youngest among them*/

#include<stdio.h>

#include<conio.h>

main()

{

int i,n,age[100],temp=0;

printf ("Enter the number of student:");

scanf("%d",&n);

printf("\n Enter the age of student:");

for(i=0;i<n;i++)

{

scanf("%d",&age[i]);

}

temp=age[0];

for(i=0;i<n;i++)

{

if(age[i]<temp)

{

temp=age[i];

}

}

//printing the age of youngest student

printf("\n The age of youngest student is: %d",temp);

getch();

}

input age of student and find the youngest one

 /* program to input the age of students and find the youngest among them*/

#include<stdio.h>

#include<conio.h>

main()

{

int i,n,age[100],temp=0;

printf ("Enter the number of student:");

scanf("%d",&n);

printf("\n Enter the age of student:");

for(i=0;i<n;i++)

{

scanf("%d",&age[i]);

}

temp=age[0];

for(i=0;i<n;i++)

{

if(age[i]<temp)

{

temp=age[i];

}

}

//printing the age of youngest student

printf("\n The age of youngest student is: %d",temp);

getch();

}