View RSS Feed

KM_Khurram

How to deal with errors in C++?

Rate this Entry
by , 30th June 2014 at 11:16 AM (2989 Views)
Assalam O Alaikum brother & sisters, I almost forgot this forum, after two years I have just join back this forum. And it's great to see that they are still active users on this forum. I'm studying Business Administration & have great interest in computer programming. Also I have interest practicing software programs in cell phones & smart phones but for that I have to practice my C, Objective C, C++ & java. As i have started practicing C++ for beginners could someone tell me. How can I fix the following error showing 'prinf' was not declared in the scope?

>>>
------------------------------------------------------------------------------------------------------------------------->>>

#include <stdio.h>
#include <stdlib.h>
/* Program that sorts a list of 10 number */
int main()
{ int cnt, inner, outer, didSwap, temp;
int nums[10]; /*Will hold the 10 numbers */
/* Fills an array with random numbers from 1 to 100 */
for (cnt = 0; cnt < 10; cnt++)
{ nums[cnt] = (rand() % 99) + 1; }
/* Print the list before it is sorted */
puts("\nHere is the list before the sort:");
for (cnt = 0; cnt < 10; cnt++)
{ printf("%d/n", nums[cnt]);}
/* Sort the array */
for (outer = 0; outer < 9; outer++)
{ didSwap = 0; /* Becomes 1 (true) if list is not yet ordered */
for (inner = outer; inner < 10; inner++)
{ if (nums[inner] < nums[outer])
{ temp = nums[inner];
nums[inner] = nums[outer];
nums[outer] = temp;
didSwap = 1; /* True because a swap took place */
}
}
if (didSwap == 0) /* Quits of list is now sorted */
{ break; }
}
/* Prints the list after it is sorted */
prinf("\nHere is the list after the sort:\n");
for (cnt = 0; cnt < 10; cnt++)
{ printf("%d/n", nums[cnt]); }
return 0;
}
majid786 and rehan_daad like this.

Submit "How to deal with errors in C++?" to Digg Submit "How to deal with errors in C++?" to Twitter Submit "How to deal with errors in C++?" to Facebook Submit "How to deal with errors in C++?" to del.icio.us Submit "How to deal with errors in C++?" to StumbleUpon

Categories
Uncategorized

Comments

  1. Charlie's Avatar
    • |
    • permalink
    wsalam
    welcome back.

    i dont think this is the right place to ask question . you should have posted in ask an expert
    _Ari3s_ likes this.
  2. DiL Da JaNi's Avatar
    • |
    • permalink
    New gcc versions got stricter, we need to add #include <cstdio>.
  3. _Ari3s_'s Avatar
    • |
    • permalink
    Agree with Charli Bro