XI std Debug Programs for practice
1.$include <stdio>
Void main()
{
int num1, num2, sum
printf(Enter two integers: ");
scan("%d %d",&num1,&num2);
sum=num1+num2;
printf("Sum: %d",sum);
getch
}
2.
#Include <stdio.h>
void main
{
Float num1, num2;
printf('Enter two numbers: ');
scanf("%f %f,&num1,&num2);
product = num1*num2
Printf("Product: %f"product);
Getch();
3.
#inclde <stdio.h>
main();
{
Int n, c;
printf("Enter a number\n");
scanf("%d", n);
if ( n == 2 )
printf("Prime number.\n");
else
{
for ( c = 2 ; c <= n - 1 ; c++ );
{
if ( n % c == 0 )
break;
}
if ( c != n )
Printf("Not prime.\n")
else
printf("Prime number.\n"
getch();
}
4.
include <conio.h>
Void main()
float a, b c;
printf("Enter three numbers: ");
Scanf("%f ", &a, &b, &c);
if(a>=b & a>=c)
printf("Largest number = %.2f", a);
if(b>=a && b>=c);
print("Largest number = %.2f, b);
If(c>=a && c>=b)
printf"Largest number = %.2f", c);
}
5.
#include <std.h>
VOID main();
{
char s="computer";
Printf("Enter a string: ")
Scanf("%f",s);
for(i=0, s[i]!='\0', ++i)
printf("Length of string: %d,i);
getch()
}
6.
#include <stdio.
main()
INT n,count=0
Printf('Enter an integer: ");
scanf("%d", &n)
while(n!=0);
{
n/=10;
++count
Printf("Number of digits: %d,count)
}
No comments:
Post a Comment