VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
program in c
1. Problem 1-Program to find sum and average of two
numbers.
ALGORITHM:
➔ START
➔ INPUT OF TWO NUMBERS “a” and “b” FROM THE USER
➔ SUM = a+b
➔ AVERAGE = (a+b)/2
➔ PRINT SUM AND AVERAGE
➔ EXIT
FLOWCHART-
INPUT:
//tanmay
#include <stdio.h>
int main()
{
int a,b,sum;
float avg;
2. printf("Enter first number :");
scanf("%d",&a);
printf("Enter second number :");
scanf("%d",&b);
sum=a+b;
avg= (float)(a+b)/2;
printf("nSum of %d and %d is = %d",a,b,sum);
printf("nAverage of %d and %d is = %fn",a,b,avg);
return 0;
}
OUTPUT-
2.Program to find the greatest of 10 numbers.
ALGORITHM:
➔ START
3. ➔ DECLARE THREE VARIABLES n[10], i, grt
➔ INPUT OF 10 NUMBERS INTO n
➔ ASSUME THE FIRST ELEMENT OF n IS THE GREATEST NUMBER
➔ COMPARE IT WITH EVERY NEXT ELEMENT OF n AND REPLACE IT IF THE
CORRESPONDING ELEMENT IS GREATER THAN THE PREVIOUS ELEMENT
➔ PRINT GRT
➔ EXIT
FLOWCHART-
INPUT-#include<stdio.h>
int main()
{
int a[10],i=0,greatest; for(i=0;i<10;i++)
{ printf("enter %d value",i+1);
scanf("%d",&a[i]);
}
5. ➔ DECLARE THREE VARIABLES P, T, R
➔ INPUT OF PRINCIPAL AMOUNT AS “P”, TIME AS “T”, RATE OF INTEREST AS “R”
➔ PRINT SIMPLE INTEREST = (P*T*R)/100
FLOWCHART-
INPUT-
#include <stdio.h>
int main()
{
int p, r, t, si ;
printf("Enter p,r and t ?n") ;
6. scanf("%d%d %d", &p, &r, &t) ;
si = (p * r* t)/100 ;
printf("Simple interest = %dn", si);
return 0 ;
}
OUTPUT-
PROBLEM 4-Program to find whether the entered number
is prime.
ALGORITHM:
7. ➔ START
➔ DECLARE THREE VARIABLES i, n, count = 0
➔ INPUT OF A NUMBER FROM USER AS n
➔ CHECK THE REMAINDER OF n%i WITH i=1 to i<=n AND ADD TO count IF
REMAINDER IS 0
➔ IF count = 2 PRINT “NUMBER IS PRIME” ELSE PRINT “NUMER IS NOT PRIME”
FLOWCHART-
INPUT-
#include<stdio.h>
int main()
{
int num;
8. printf("Enter the numbern");
scanf("%d",&num);
int count=0;
for(int i=2; i<num; i++)
{
if(num%i==0)
count++;
}
if(count!=0)
{
printf("Not a prime numbern");
}
else
{
printf("Prime numbern");
}
return 0;
}
OUTPUT-