31. The Program that accept a number from the user and will printf whether it is positive
or negative.
#include<stdio.h>
#include<conio.h>
Void main()
{
int num;
printf("\n Enter any Number:");
scanf("%d", & num);
if(num<0)
printf("\n Number is a Negative Number");
else
printf("\n Number is a Positive Number");
getch();
}
_________________________________________________________________________________
32. Write a Program calculates the average of the non-negative in list of n Numbers.
#include<stdio.h>
#include<conio.h>
Void main()
{
int n, i, avg;
float x, average, sum;
avg = 0;
sum = 0.0;
printf("How many numbers?\n");
scanf("%d", &n);
for(i=1; i<=n; ++i)
{
printf("x= ");
scanf("%&", &x);
if(x<0)
continue;
sum ++ = x;
++ avg;
}
average = sum/avg;
printf("\n The Average is %f\n", average);
getch();
}
_________________________________________________________________________________
33. Example of Goto Statement.
#include<stdio.h>
#include<conio.h>
#include<math.h>
Void main()
{
double r,y;
int count=1;
printf("Enter the five real Numbers:");
read;
printf("%d", &x);
if(x<0)
printf("Number is Negative");
else
{
y = sqrt(x)
}
printf("%d",y);
count++;
if(count<=5)
goto read;
printf("The Five Numbers square root is ended");
getch();
}
_________________________________________________________________________________
34. Write a Program to accept 10 numbers from the user and will print the total number of
positive, total number of negative and zero input by the user.
#include<stdio.h>
#include<conio.h>
Void main()
{
int num, p=n=z=0,i;
printf("\n Enter any ten numbers:\n");
for(i=1; i<=10; ++i)
{
scanf(%d", & num);
if(num>0)
++p;
else if(num<0)
++n;
else
++z;
}
printf("\n Total no. of Positive=%d", p);
printf("\n Total no. of Negative=%d", n);
printf("\n Total no. of Zeros=%d", z);
getch();
}
_________________________________________________________________________________
35. Write a Program to reads a character from the keyboard and print whether it is vowel or
not vowel.
#include<stdio.h>
#include<conio.h>
Void main()
{
char ch;
printf("%c", & ch);
if((ch == 'a') || (ch == 'A') || (ch == 'e') || (ch == 'E') || (ch == 'i') || (ch == 'I') || (ch == 'o') || (ch == 'O') || (ch == 'u') || (ch == 'U'))
printf("\n Letter (%c) is vowel", ch);
else
printf("\n Letter (%c) is vowel", ch);
getch();
}
*********************************************************************************
or negative.
#include<stdio.h>
#include<conio.h>
Void main()
{
int num;
printf("\n Enter any Number:");
scanf("%d", & num);
if(num<0)
printf("\n Number is a Negative Number");
else
printf("\n Number is a Positive Number");
getch();
}
_________________________________________________________________________________
32. Write a Program calculates the average of the non-negative in list of n Numbers.
#include<stdio.h>
#include<conio.h>
Void main()
{
int n, i, avg;
float x, average, sum;
avg = 0;
sum = 0.0;
printf("How many numbers?\n");
scanf("%d", &n);
for(i=1; i<=n; ++i)
{
printf("x= ");
scanf("%&", &x);
if(x<0)
continue;
sum ++ = x;
++ avg;
}
average = sum/avg;
printf("\n The Average is %f\n", average);
getch();
}
_________________________________________________________________________________
33. Example of Goto Statement.
#include<stdio.h>
#include<conio.h>
#include<math.h>
Void main()
{
double r,y;
int count=1;
printf("Enter the five real Numbers:");
read;
printf("%d", &x);
if(x<0)
printf("Number is Negative");
else
{
y = sqrt(x)
}
printf("%d",y);
count++;
if(count<=5)
goto read;
printf("The Five Numbers square root is ended");
getch();
}
_________________________________________________________________________________
34. Write a Program to accept 10 numbers from the user and will print the total number of
positive, total number of negative and zero input by the user.
#include<stdio.h>
#include<conio.h>
Void main()
{
int num, p=n=z=0,i;
printf("\n Enter any ten numbers:\n");
for(i=1; i<=10; ++i)
{
scanf(%d", & num);
if(num>0)
++p;
else if(num<0)
++n;
else
++z;
}
printf("\n Total no. of Positive=%d", p);
printf("\n Total no. of Negative=%d", n);
printf("\n Total no. of Zeros=%d", z);
getch();
}
_________________________________________________________________________________
35. Write a Program to reads a character from the keyboard and print whether it is vowel or
not vowel.
#include<stdio.h>
#include<conio.h>
Void main()
{
char ch;
printf("%c", & ch);
if((ch == 'a') || (ch == 'A') || (ch == 'e') || (ch == 'E') || (ch == 'i') || (ch == 'I') || (ch == 'o') || (ch == 'O') || (ch == 'u') || (ch == 'U'))
printf("\n Letter (%c) is vowel", ch);
else
printf("\n Letter (%c) is vowel", ch);
getch();
}
*********************************************************************************
0 comments:
Post a Comment