Message from C, C++ discussions

December 2019

β€” πŸ‘


#include <stdio.h>

//Compiler version gcc 6.3.0

int main()
int i, sum=0,A,B;
printf ("input A : ");
scanf ("%d",&A);
printf ("input B : ");
scanf ("%d",&B);
printf("Numbers between A and B, divisible by 3 : \n");
printf(" ");

β€” WanzOr Have a look at this and try understanding it

β€” Thank you

β€” Very much

β€” One modificationβ€”-> for(i=A;i<=B;i++)
Not i<B

β€” Purge complete.

β€” OMG

β€” Welcome!

β€” πŸ˜Š

β€” Char firstCapitalChar(char* str, int length, char putHereA){

if(str[length] == putHereA)return(str[length]);
else if(length == 0)return (char)0;
else if(putHereA == 'Z')return firstCapitalChar(str, length - 1, 'A');

return firstCapitalChar(str, length, putHereA+1);
} this recursive function need to return me the first capital letter but it returning the last capital letter why?

Message permanent page

β€” Maybe you need to pass the starting index and the last index of the string into your recursive function.... I made one and its working fine... Have a look
using namespace std;
char first_capital(string str,int start,int len)
return str[len];
else if(str[start]>='A'&&str[start]<='Z')
return str[start];
return first_capital(str,start+1,len);
int main()
string str;
cout<<"The first capital letter in the string is : "<<first_capital(str,0,str.length());
return 0;

Message permanent page