Hi guys. . I'm a newbie /maybe dummy /
teacher gave me homework.. but I can"n solve it.. Can sum1 help me??
Write a C program that will input a 9-digit Credit Card Number, and will check whether iit is valid or not (i.e. to examine if the last 2 digits of the Credit Card Number can be generated from the first 7-digit number)
I've started this thread appealing to lead.smart34's advice.. All "responsibilities" belongs to her/him..
Now let present my sollution.
1- enter 9 digited numbers
2- get 3rd 4 and 5th digits and create a 3 digited number. say this number x
3- find square of x
4- get 8 and 9 th digits and say this 2 digited number y
5- compare x and y in (mod10)
6.a- if they're equal in mod10 print "valid credti card number"
6.b- else "invalid credit card number"
Firstly I defined the a1, a2 ... a9 variables.
Then wrote the printf("Enter 9 digited c.c. numba" );
then, scanf all a1 a2 ... a9
I dont know how to get a3a4a5 and a8a9 as a number.
I can do the end.. Such let's say x to the square of a3a4a5.. and y to a8a9 /two digited number/
Then we can compare .
if(x %10== y)
printf("valid c.c. number");
printf("invalid c.c. number");
I hope I could describe the problem..
A general problem
I ll giv u a code which i think can b useful 2 convert frm individual digits 2 a no.supose u hav 3 diferent no.a,a,a.u can combin dem by s=100*a+10*a+a similarly p=10*a+a
I ll giv u a code which i think can b useful 2 convert frm individual digits 2 a no.supose u hav 3 diferent no.a,a,a.u can combin dem by s=100*a+10*a+a similarly p=10*a+a.i hope u ca do d rest