Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/ #include <stdio.h> int main() { int X, N, a,b=0; scanf("%d %d", &X, &N); while(N<=0) scanf("%d", &N); for(a=1; a<=N; a++) { b+=X; X++; } printf("%d\n",b); return 0; }
I had a lot of trouble resolving this problem
ReplyDeletewhy there is no braces in while loop
ReplyDeleteplease help me Sir.
#include
Deleteint main()
{
int a,n,i,j,sum;
scanf("%d%d",&a,&n);
while(n<=0)
{
scanf("%d",&n);
if(n>0) break;
}printf("%d\n",(a*n)+1);
}
where is my problem sir!
ReplyDelete#include
ReplyDeleteint main()
{
int a,n,i,j,sum;
scanf("%d%d",&a,&n);
while(n<=0)
{
scanf("%d",&n);
if(n>0) break;
}printf("%d\n",(a*n)+1);
}
input 3 3 then saw the answer ,
ReplyDeleteit's 10, but correct answer is 12 ,
not only input 3 3 you can try more, then calculate on a page .