Write a program that takes a 3 digit number n and finds out
whether the number 2^n + 1 is prime, or if it is not prime
find out its factors
Answer Posted / nitin garg
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
int num,i,sum=1,flag=0;
printf("enter three digit no
");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
sum=sum*2;
}
sum++;
printf("
%d",sum);
for(i=2;i<sum/2;i++)
{
if(sum%i==0)
flag=1;
}
if(flag==0)
printf("
number is prime");
printf("
factor is below:
");
for(i=1;i<=sum;i++)
{
if(sum%i==0)
printf("%d ",i);
}
getch();
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can the size of an array be declared at runtime?
Is c a great language, or what?
What are the advantages of using Unions?
What is the scope of global variable in c?
What are type modifiers in c?
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer
What is the translation phases used in c language?
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
develop algorithms to add polynomials (i) in one variable
What is c mainly used for?
What is a c token and types of c tokens?
What is strcpy() function?
What is a constant?
Which of the following operators is incorrect and why? ( >=, <=, <>, ==)
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software