Add first ten odd numbers in C

| December 15, 2010 | 0 Comments

This article demonstrates how to add first ten odd numbers in C starting from 1. I am writing this article as I was preparing assignment of SMU MCA First Semester August 2010 MC0061. So I too faced problem for that. Well … this is solution for those students.

#include
main()
{
     int num=1;
     int total,counter;

 printf("Checking first ten odd numbers and adding them together...\n");

 while(counter<10)
 {
 if(num%2!=0)
 {
  printf("%d\n",num);
  total=total+num;
  counter++;
 }
 num++;
 }
 printf( "Total of first ten odd numbers is: %d\n", total );
}

Tags:

Category: .NET

Leave a Reply

Sex Chat Live Jasmin WP-Clear 3.0 Theme
%d bloggers like this:
bject_id ASC 65 | 0.0006 | enabled | not cached | 11135 | SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (225,226,227,228,229) AND wp_posts.post_type = 'nav_menu_item' AND ((wp_posts.post_status = 'publish')) ORDER BY wp_posts.menu_order ASC 66 | 0.0002 | enabled | not cached | 2087 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (226) ORDER BY meta_id ASC 67 | 0.0002 | enabled | not cached | 2087 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (229) ORDER BY meta_id ASC 68 | 0.0002 | enabled | not cached | 2087 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (227) ORDER BY meta_id ASC 69 | 0.0002 | enabled | not cached | 2087 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (225) ORDER BY meta_id ASC 70 | 0.0002 | enabled | not cached | 2087 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (228) ORDER BY meta_id ASC 71 | 0.0003 | enabled | not cached | 4495 | SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category') AND t.term_id IN ( 4,8,9,2,3 ) ORDER BY t.name ASC 72 | 0.0001 | enabled | cached | 736 | SELECT t.term_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category') AND tr.object_id IN (11) ORDER BY t.name ASC 73 | 0.0001 | enabled | not cached | 529 | SELECT option_value FROM wp_options WHERE option_name = 'text_direction' LIMIT 1 74 | 0.0003 | enabled | not cached | 4903 | SELECT * FROM wp_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 11 ORDER BY comment_date_gmt ASC 75 | 0.0002 | enabled | not cached | 632 | SELECT p.ID FROM wp_posts AS p WHERE p.post_date < '2010-12-15 12:21:00' AND p.post_type = 'post' AND p.post_status = 'publish' ORDER BY p.post_date DESC LIMIT 1 76 | 0.0002 | enabled | not cached | 631 | SELECT p.ID FROM wp_posts AS p WHERE p.post_date > '2010-12-15 12:21:00' AND p.post_type = 'post' AND p.post_status = 'publish' ORDER BY p.post_date ASC LIMIT 1 77 | 0.001 | enabled | not cached | 3091 | SELECT p.ID AS 'id', p.post_title AS 'title', p.post_date AS 'date', p.post_author AS 'uid', ( SUM(v.pageviews)/(IF ( DATEDIFF('2017-01-31 19:04:34', DATE_SUB('2017-01-31 19:04:34', INTERVAL 1 WEEK)) > 0, DATEDIFF('2017-01-31 19:04:34', DATE_SUB('2017-01-31 19:04:34', INTERVAL 1 WEEK)), 1) ) ) AS 'avg_views' FROM wp_popularpostssummary v LEFT JOIN wp_posts p ON v.postid = p.ID WHERE 1 = 1 AND p.post_type IN('post','page') AND v.last_viewed > DATE_SUB('2017-01-31 19:04:34', INTERVAL 1 WEEK) AND p.post_password = '' AND p.post_status = 'publish' GROUP BY v.postid ORDER BY avg_views DESC LIMIT 5; 78 | 0.0002 | enabled | not cached | 11898 | SELECT * FROM wp_posts WHERE ID = 1 LIMIT 1 79 | 0.0002 | enabled | not cached | 9642 | SELECT * FROM wp_posts WHERE ID = 26 LIMIT 1 80 | 0.0003 | disabled (query) | not cached | 0 | SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 0, 5 81 | 0.0001 | disabled (query) | not cached | 0 | SELECT FOUND_ROWS() 82 | 0.0003 | enabled | not cached | 23663 | SELECT wp_posts.* FROM wp_posts WHERE ID IN (353,339,2,3) 83 | 0.0007 | enabled | not cached | 6478 | SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag', 'post_format') AND tr.object_id IN (2, 3, 339, 353) ORDER BY t.name ASC 84 | 0.0006 | enabled | not cached | 10510 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (2,3,339,353) ORDER BY meta_id ASC 85 | 0.0019 | enabled | not cached | 7307 | SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,100) AS com_excerpt FROM wp_comments LEFT OUTER JOIN wp_posts ON (wp_comments.comment_post_ID = wp_posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 5 86 | 0.0002 | enabled | not cached | 14705 | SELECT * FROM wp_posts WHERE ID = 42 LIMIT 1 87 | 0.0004 | enabled | not cached | 2074 | SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC 88 | 0.0002 | enabled | cached | 4714 | SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category') ORDER BY t.name ASC 89 | 0.0005 | enabled | not cached | 8853 | SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag') AND tt.count > 0 ORDER BY tt.count DESC LIMIT 200 90 | 0.0002 | enabled | not cached | 3470 | SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'nav_menu' AND t.term_id = 33 LIMIT 1 91 | 0.0002 | enabled | not cached | 946 | SELECT tr.object_id FROM wp_term_relationships AS tr INNER JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('nav_menu') AND tt.term_id IN ('33') ORDER BY tr.object_id ASC 92 | 0.0005 | enabled | not cached | 11910 | SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (231,232,234,244,289,306) AND wp_posts.post_type = 'nav_menu_item' AND ((wp_posts.post_status = 'publish')) ORDER BY wp_posts.menu_order ASC 93 | 0.0002 | enabled | not cached | 2109 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (234) ORDER BY meta_id ASC 94 | 0.0002 | enabled | not cached | 2092 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (231) ORDER BY meta_id ASC 95 | 0.0002 | enabled | not cached | 2086 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (232) ORDER BY meta_id ASC 96 | 0.0002 | enabled | not cached | 2086 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (289) ORDER BY meta_id ASC 97 | 0.0002 | enabled | not cached | 2086 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (244) ORDER BY meta_id ASC 98 | 0.0002 | enabled | not cached | 2086 | SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (306) ORDER BY meta_id ASC 99 | 0.0005 | enabled | not cached | 26416 | SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (207,209,279,239,301) AND wp_posts.post_type = 'page' AND ((wp_posts.post_status = 'publish')) ORDER BY wp_posts.post_date DESC 100 | 0.0001 | enabled | cached | 736 | SELECT t.term_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category') AND tr.object_id IN (11) ORDER BY t.name ASC 101 | 0.0001 | enabled | cached | 559 | select meta_key from wp_postmeta where meta_key like '_wp_page_template' and meta_value like 'page-youtube.php' 102 | 0.0001 | enabled | cached | 625 | select meta_key from wp_postmeta where meta_key like '_wp_page_template' and meta_value like 'page-portfolio.php' 103 | 0.0001 | enabled | cached | 559 | select meta_key from wp_postmeta where meta_key like '_wp_page_template' and meta_value like 'page-youtube.php' 104 | 0.0001 | enabled | cached | 625 | select meta_key from wp_postmeta where meta_key like '_wp_page_template' and meta_value like 'page-portfolio.php' -->