Thread: C programming Beginner Question (More Helpful if provide me with the code)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2021
    Posts
    6

    Lightbulb

    Quote Originally Posted by Salem View Post
    So what have you managed to do so far?

    Can you for example input two numbers?
    Can you add them?
    insert
    Code:
    #include<stdio.h>
    int main(){
    	int a,b,sum,rev=0,remainder,i;
    	printf("Please enter the two integers:");
    	scanf("%d%d",&a,&b);
    	
    	sum=a+b;
    	while(sum!=0){
    		remainder=sum%10;
    		rev=rev*10+remainder;
    		sum/=10;
    	}
    	
    	for(i=0;i<=sum;i++){
    	if(sum==i*i){
    		printf("Alice wins");
    	}
    	else if(rev==i*i)
    	{printf("Bob wins");
    	}
    	return 0;
    	}
    }
    I am struggling here...
    Last edited by Kennyjai12345; 12-07-2021 at 11:38 PM.

  2. #2
    Registered User
    Join Date
    Dec 2021
    Posts
    6
    But I don't know why when I input 8 and 10, it still output Alice wins. It should be Bob wins.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. beginner plzz help urgent
    By sara101 in forum C Programming
    Replies: 11
    Last Post: 01-14-2007, 10:38 PM
  2. Replies: 14
    Last Post: 12-06-2006, 04:58 PM
  3. General question from a beginner to Windows C++ programming
    By Kontan in forum Windows Programming
    Replies: 1
    Last Post: 09-29-2006, 08:03 PM
  4. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM
  5. Beginner needs help w/ran. nums. in arrays - URGENT!
    By madhouse199 in forum C++ Programming
    Replies: 3
    Last Post: 12-12-2001, 07:12 AM

Tags for this Thread