Professional Documents
Culture Documents
#include <stdio.h>
int main()
{
/* A nice long string */
char string[256];
getchar();
}
No 20
#include<stdio.h>
int main ()
{
char string[];
string[0] = 'C';
string[1] = 'P';
string[2] = 'r';
string[3] = 'o';
string[4] = 'g';
string[5] = 'r';
string[6] = 'a';
string[7] = 'm';
string[8] = 'm';
string[9] = 'i';
string[10]= 'n';
string[11] = 'g';
printf ("%s", string);
return 0;
}
no16.
14.
/*C program to check whether a number entered by user is prime or not using
function with no arguments but having return value */
#include <stdio.h>
int input();
int main()
{
int num,i,flag = 0;
num=input();
15.
/*Program to check whether a number entered by user is prime or not using
function with arguments and no return value */
#include <stdio.h>
void check_display(int n);
int main()
{
int num;
printf("Enter positive enter to check:\n");
scanf("%d",&num);
check_display(num); /* Argument num is passed to function. */
return 0;
}
void check_display(int n){
/* There is no return value to calling function. Hence, return type of function is
void. */
int i, flag = 0;
for(i=2; i<=n/2; ++i){
if(n%i==0){
flag = 1;
break;
}
}
if(flag == 1)
printf("%d is not prime",n);
else
printf("%d is prime", n);
}